package com.xjrsoft.module.customerTwo.AppManage.companyinfo.service.impl;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.xjrsoft.core.tool.utils.StringUtil;
import com.xjrsoft.module.customerTwo.AppManage.companyinfo.entity.DwCompanyInfo;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.xjrsoft.core.tool.utils.CollectionUtil;
import java.util.ArrayList;
import com.xjrsoft.module.customerTwo.AppManage.companyinfo.dto.DwCompanyInfoListDto;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.xjrsoft.common.page.ConventPage;
import com.xjrsoft.common.page.PageOutput;
import java.util.List;
import com.xjrsoft.module.customerTwo.AppManage.companyinfo.mapper.DwCompanyInfoMapper;
import com.xjrsoft.module.customerTwo.AppManage.companyinfo.service.IDwCompanyInfoService;
import com.xjrsoft.core.mp.base.BaseService;
import com.xjrsoft.core.tool.utils.Func;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;

/**
 *  服务实现类
 *
 * @author lisen
 * @since 2024-05-31
 */
@Service
@AllArgsConstructor
public class DwCompanyInfoServiceImpl extends BaseService<DwCompanyInfoMapper, DwCompanyInfo> implements IDwCompanyInfoService {


	@Override
	public IPage<DwCompanyInfo> getPageList(DwCompanyInfoListDto pageListDto) {
		Wrapper<DwCompanyInfo> wrapper = Wrappers.<DwCompanyInfo>query().lambda()
				.like(!StringUtil.isEmpty(pageListDto.getCompany_id()), DwCompanyInfo::getCompanyId, pageListDto.getCompany_id())
				.like(!StringUtil.isEmpty(pageListDto.getCompany_name()), DwCompanyInfo::getCompanyName, pageListDto.getCompany_name())
				.eq(!StringUtil.isEmpty(pageListDto.getEmployee()), DwCompanyInfo::getEmployee, pageListDto.getEmployee())
				.eq(!StringUtil.isEmpty(pageListDto.getG_employee()), DwCompanyInfo::getGEmployee, pageListDto.getG_employee())
				.eq(!StringUtil.isEmpty(pageListDto.getCl_lat()), DwCompanyInfo::getClLat, pageListDto.getCl_lat())
				.eq(!StringUtil.isEmpty(pageListDto.getCl_lng()), DwCompanyInfo::getClLng, pageListDto.getCl_lng())
				.like(!StringUtil.isEmpty(pageListDto.getProduct1()), DwCompanyInfo::getProduct1, pageListDto.getProduct1())
				.like(!StringUtil.isEmpty(pageListDto.getProduct2()), DwCompanyInfo::getProduct2, pageListDto.getProduct2())
				.like(!StringUtil.isEmpty(pageListDto.getProduct3()), DwCompanyInfo::getProduct3, pageListDto.getProduct3())
				.like(!StringUtil.isEmpty(pageListDto.getProduct4()), DwCompanyInfo::getProduct4, pageListDto.getProduct4())
				.like(!StringUtil.isEmpty(pageListDto.getProduct5()), DwCompanyInfo::getProduct5, pageListDto.getProduct5())
				.ge(!StringUtil.isEmpty(pageListDto.getCreate_date_Start()), DwCompanyInfo::getCreateDate, pageListDto.getCreate_date_Start())
				.le(!StringUtil.isEmpty(pageListDto.getCreate_date_End()), DwCompanyInfo::getCreateDate, pageListDto.getCreate_date_End())
				.ge(!StringUtil.isEmpty(pageListDto.getUpdate_date_Start()), DwCompanyInfo::getUpdateDate, pageListDto.getUpdate_date_Start())
				.le(!StringUtil.isEmpty(pageListDto.getUpdate_date_End()), DwCompanyInfo::getUpdateDate, pageListDto.getUpdate_date_End())
				.like(!StringUtil.isEmpty(pageListDto.getCreater()), DwCompanyInfo::getCreater, pageListDto.getCreater())
				.like(!StringUtil.isEmpty(pageListDto.getUpdater()), DwCompanyInfo::getUpdater, pageListDto.getUpdater());
		return this.page(ConventPage.getPage(pageListDto), wrapper);
	}

	@Override
	public Integer addDwCompanyInfo(DwCompanyInfo dwCompanyInfo) {
		boolean isSuccess = this.save(dwCompanyInfo);
		return isSuccess ? dwCompanyInfo.getId() : null;
	}

	@Override
	public boolean updateDwCompanyInfo(Integer id, DwCompanyInfo dwCompanyInfo) {
		dwCompanyInfo.setId(id);
		return this.updateById(dwCompanyInfo);
	}

	public boolean delete(String ids) {
		List<String> idList = Func.toStrList(ids);
		if (this.removeByIds(idList)) {
			return true;
		}
		return false;
	}

}